package JD.Q2;

import java.util.Scanner;

// 注意类名必须为 Main, 不要有任何 package xxx 信息
public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        // 注意 hasNext 和 hasNextLine 的区别
        int n = in.nextInt();
        int[] arr = new int[n];
        for(int i = 0; i < n; i++){
            arr[i] = in.nextInt();
        }
        int count = 0 ;
        for(int i = 0; i < n-1; i++){
            if(arr[i] > arr[i+1]){
                if(i + 2 < n && arr[i] > arr[i+2]){
                    reverse(arr,i,i+2);
                    //count++;
                    break;
                }else{
                    reverse(arr,i,i+1);
                    count++;
                }
            }
        }
        System.out.print(count);
    }
    static void reverse(int[] arr, int start, int end){
        while(start<end){
            int temp = arr[start];
            arr[start] = arr[end];
            arr[end] = temp;
            start++;
            end--;
        }
    }
}